package net.lab1024.smartadmin.module.weapp.login;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.lab1024.smartadmin.common.anno.NoNeedLogin;
import net.lab1024.smartadmin.common.anno.OperateLog;
import net.lab1024.smartadmin.common.domain.ResponseDTO;
import net.lab1024.smartadmin.constant.SwaggerTagConst;
import net.lab1024.smartadmin.module.system.login.domain.LoginDetailVO;
import net.lab1024.smartadmin.module.weapp.login.domain.LoginInfoVO;
import net.lab1024.smartadmin.module.weapp.login.domain.WeappLoginDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 小程序授权登入
 *
 * @author 五千
 * @date 2021年03月09日上午11:46:04
 */
@RestController
@Api(tags = {SwaggerTagConst.Weapp.MANAGER_USER_LOGIN})
@OperateLog
public class WeappLoginController {

    @Autowired
    private WeappLoginService loginService;

    @PostMapping("/weapp/login")
    @ApiOperation(value = "微信小程序登录", notes = "微信小程序登录")
    @NoNeedLogin
    public ResponseDTO<LoginInfoVO> login(@Valid @RequestBody WeappLoginDTO loginForm, HttpServletRequest request) {
        return loginService.login(loginForm, request);
    }
}
